package day10;

import java.util.ArrayList;
import java.util.Scanner;

public class UserTest {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        ArrayList<User> list = new ArrayList<>();
        User u1 = new User(001,"张三","1234566");
        User u2 = new User(002,"李四","1234562");
        User u3 = new User(003,"王五","1234531");
        list.add(u1);
        list.add(u2);
        list.add(u3);
        System.out.println("请输入要查找的id：");
        int find = sc.nextInt();
        int  result = contains(list,find);
        System.out.println(result);
    }
    public static int  contains (ArrayList<User> list , int id){
        for(int i=0;i<list.size();i++){
            if(list.get(i).id==id) {
                return i;
            }
        }
        return -1;
    }
}
